import java.util.ArrayList;

public class map {
    ArrayList<room> rooms = new ArrayList<room>();
    // this is the width of the map, ie 3 is a 3x3 map.
    int size = 3;

    // the player object that was created in the map class initialization is passed
    // to the run method, this object will be passed to all room objects so that the
    // rooms are able to change the player's stats as he finds loot or fights monsters.
    public void run(player p) {

        for (int x = 0; x < size; x++) {
            for (int y = 0; y < size; y++) {
                // these for loops are used to create all possible coordinates for a particular
                // room size. Within the 2nd for loop we are able to assign each room's unique attributes.
                // with the set coordinates method.
                room r = new room();
                r.setcoordinates(x,y,size);
                rooms.add(r);
            }
        }
    
        // This is just for testing, at the moment it just outputs the coordinates and exits of
        // each room object in the 'rooms' arraylist. This does not need to be run once the game
        // is finished.
        for (int i = 0; i < size * size; i++) {
            ArrayList<String> exits = new ArrayList<String>();
            exits = rooms.get(i).exits;

            System.out.printf("%d,%d: ", rooms.get(i).x, rooms.get(i).y);
            for (int exiti = 0; exiti < exits.size(); exiti++) {
                System.out.printf("%s ", exits.get(exiti));
            }
            System.out.println();
        }
    
        for (int i = 0; i < rooms.size(); i++) {
            if ((rooms.get(i).x == 0) && (rooms.get(i).y == 0)) {
                rooms.get(i).run(p,rooms);
            } else { }
        }
    }
}
